home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
fielddh.exe
/
COLOR_AP.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-04-30
|
12KB
|
317 lines
{*--------------------------------------------------------------------------*}
{* To Use the COLOR features (Buttons, etc) you must: *}
{* 0: Have your application be a PCOLOR_APP from this unit!!!! *}
{* 1: Have your DIALOG be a PCOLOR_DIALOG from this unit! *}
{* 2: Pascal-Code the PCOLOR_BUTTONS/PCOLOR_STATICTEXT exactly *}
{* the same as if they were 'normal' TButton/TStaticText. *}
{* 3: The FIELDS unit knows about these COLOR objects. *}
{*--------------------------------------------------------------------------*}
UNIT Color_App; {Colored Application Buttons/TEXT!!}
INTERFACE
USES App, {TVISION, modified version to handle COLOR buttons!}
Dialogs, {TVISION, button}
Views, {TVision, titlestr}
Objects; {TVision, misc}
CONST
Button_Color_Default :byte = 0; {green}
Button_Black :byte = 1;
Button_Dk_Blue :byte = 2;
Button_Green :byte = 3;
Button_Cyan :byte = 4;
Button_Red :byte = 5;
Button_Purple :byte = 6;
Button_Brown :byte = 7;
Button_Grey :byte = 8;
Button_Dk_Grey :byte = 9;
Button_Lt_Blue :byte = 10;
Button_Lt_Green :byte = 11;
Button_Lt_Cyan :byte = 12;
Button_Lt_Red :byte = 13;
Button_Lt_Purple :byte = 14;
Button_Yellow :byte = 15;
Button_White :byte = 16;
TYPE
PColor_InputLine = ^Color_Inputline;
Color_InputLine = OBJECT(TInputLine)
constructor Init (var Bounds: TRect; AMaxLen: Integer;
Button_Color_ID : byte); {new parameter!}
function GetPalette : PPalette; virtual; {MUST Override!}
private
Color : word;
end; {color_inputline}
PColor_Button = ^Color_Button;
Color_Button = object(DIALOGS.TButton)
constructor Init (var Bounds : OBJECTS.TRect;
ATitle : VIEWS.TTitleStr;
ACommand : Word;
AFlags : Byte;
Button_Color_ID : byte); {new parameter!}
function GetPalette : PPalette; virtual; {MUST Override!}
procedure New_Color (Button_Color_ID : Byte);
function Get_Color : integer;
procedure Hide_Shadow;
private
Color : word;
Shadow_Hidden : boolean;
end; {Color_Button}
PColor_StaticText = ^Color_StaticText;
Color_StaticText = object(DIALOGS.TStaticText)
constructor Init (var Bounds : OBJECTS.TRect;
AText : string;
Button_Color_ID : byte); {new parameter!}
function GetPalette : PPalette; virtual; {MUST Override!}
private
Color : word;
end; {Color_StaticText}
PColor_Dialog = ^Color_Dialog;
Color_Dialog = object(TDialog)
constructor init (var bounds: TRect; ATitle: TTitleStr);
function GetPalette : PPalette; virtual; {MUST Override!}
end; {Color_Dialog}
PColor_Application = ^Color_Application;
{this elimates need to tweak APP.pas}
Color_Application = object(TApplication)
function GetPalette : PPalette; virtual; {MUST Override!}
end; {Color_Application}
{*-----------------------------------------------------------*}
{* If you want blinking, you must call SetBlink(TRUE) *}
{* after a color dialog *}
{*-----------------------------------------------------------*}
procedure SetBlink(State: Boolean);
{*************************************************************************}
{*************************************************************************}
{*************************************************************************}
IMPLEMENTATION
{*************************************************************************}
procedure SetBlink(State: Boolean); assembler; {by steve shafer}
asm
mov ax,$1003
mov bl,state
push bp
int $10
pop bp
end; {setblink}
{**************************************************************************}
constructor Color_InputLine.Init;
begin
TInputLine.Init (Bounds, AMaxLen);
Color := Button_Color_ID;
end; {init}
{**************************************************************************}
function Color_InputLine.GetPalette : PPalette;
const
D_Palette : string[4] = '';
begin
{*-----------------------------------------------------------------------*}
{* Must be VAR rather than const to RESET to default each time! *}
{* (changes to a const version of D_Palette is REMEMBERED!) *}
{*-----------------------------------------------------------------------*}
{#19#19#20#21; => TVision default colors for TInputLine}
D_Palette := TInputLine.GetPalette^;
IF ((Color > 0) and (Color < 17)) THEN
BEGIN
D_Palette[1] := CHAR(30+(Color*3)); {normal}
D_Palette[2] := D_Palette[1];
D_Palette[3] := CHAR(30+(Color*3)+1); {selected}
END;
GetPalette := @D_Palette;
end; {getpalette}
{**************************************************************************}
constructor Color_Button.Init;
begin
TButton.Init (Bounds, ATitle, ACommand, AFlags);
Color := Button_Color_ID;
Shadow_Hidden := FALSE;
end; {init}
{**************************************************************************}
procedure Color_Button.New_Color;
begin
Color := Button_Color_ID;
Draw; {display the change}
end; {new_color}
{**************************************************************************}
function Color_Button.Get_Color : integer;
begin
Get_Color := Color;
end; {get_color}
{**************************************************************************}
procedure Color_Button.Hide_Shadow;
begin
Shadow_Hidden := TRUE;
Draw; {display the change}
end; {hide_shadow}
{**************************************************************************}
function Color_Button.GetPalette : PPalette;
{* NOTE: Colors assumes use of COLOR Monitor!!!! *}
{ bckgrnd / letters
49=NO SHADOW (maybe want to instead use char[1]?)
0 - black 4 - red 8 - dark gray C - light red
1 - blue 5 - magenta 9 - light blue D - light magenta
2 - green 6 - brown A - light green E - yellow
3 - cyan 7 - light gray B - light cyan F - white
} {see pg 107 on methodology}
const
D_Palette : string[8] = '';
begin
{*-----------------------------------------------------------------------*}
{* Must be VAR rather than const to RESET to default each time! *}
{* (changes to a const version of D_Palette is REMEMBERED!) *}
{*-----------------------------------------------------------------------*}
{#10#11#12#13#14#14#14#15; => TVISION default colors for TButton}
D_Palette := TButton.GetPalette^;
IF ((Color > 0) and (Color < 17)) THEN
BEGIN
D_Palette[1] := CHAR(30+(Color*3)); {normal}
D_Palette[2] := D_Palette[1]; {normal for highlights}
D_Palette[3] := CHAR(30+(Color*3)+1); {selected button}
D_Palette[5] := CHAR(30+(Color*3)+2); {shortcut}
D_Palette[6] := D_Palette[5];
D_Palette[7] := D_Palette[6];
END;
IF (Shadow_Hidden)
THEN D_Palette[8] := #81; {set to EXTENDED set (background)}
GetPalette := @D_Palette;
end; {getpalette}
{**************************************************************************}
constructor Color_StaticText.Init;
begin
TStaticText.Init (Bounds, AText);
Color := Button_Color_ID;
end; {init}
{**************************************************************************}
function Color_StaticText.GetPalette : PPalette;
const
D_Palette : string[1] = '';
begin
{*-----------------------------------------------------------------------*}
{* Must be VAR rather than const to RESET to default each time! *}
{* (changes t